/*
 * Copyright (C) 2012 artit91
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package rpg.entities.properties;

import java.util.logging.Logger;
import rpg.Game;
import rpg.Location;
import rpg.entities.Sprite;

/**
 *
 * @author artit91
 */
public class CreatureProperty extends Property {

    private int maxHealth;
    private int health;
    private int speed;
    private int dmgMin;
    private int dmgMax;
    private int level;
    private int currXP;
    private int unspentTalentPoint;
    
    private Location nextMove;
    private Sprite targetEntity;

    //Creature properties like hp, fraction, etc...
    public CreatureProperty(final String type, final int maxHealth, final int health,
            final int speed, Location location, Sprite targetEntity, final int dmgMin, final int dmgMax,final int level,final int currXP,final int unspentTalentPoints) {
        setType(type);
        this.maxHealth = maxHealth;
        this.health = health;
        this.speed = speed;
        setLocation(location);
        this.targetEntity = targetEntity;
        this.dmgMin = dmgMin;
        this.dmgMax = dmgMax;
        this.level = level;
        this.currXP=currXP;
        this.unspentTalentPoint=unspentTalentPoints;
        nextMove = new Location(location.getX(), location.getY(), false, Game.getInstance().getActual());
    }
    private static final Logger LOG = Logger.getLogger(CreatureProperty.class.getName());

    public int getMaxHealth() {
        return maxHealth;
    }

    public int getCurrXP() {
        return currXP;
    }

    public int getLevel() {
        return level;
    }
    public void accountXp(int xpBoost){
        if(level<=40){
        this.currXP+=xpBoost;
        checklevelup();
        }
    }
    
    private void checklevelup(){
       if(currXP>=100 ){
            level+=currXP/100;
            currXP=currXP%100;
            unspentTalentPoint+=(currXP/100)*4;
            System.out.println("Level up:"+level);
       }
        
        
    }
            
    public void setMaxHealth(final int maxHealth) {
        this.maxHealth = maxHealth;
    }

    public int getHealth() {
        return health;
    }

    public void setHealth(final int health) {
        this.health = health;
    }

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(final int speed) {
        this.speed = speed;
    }

    public Sprite getTargetEntity() {
        return targetEntity;
    }

    public void setTargetEntity(final Sprite targetEntity) {
        this.targetEntity = targetEntity;
    }

    public int getDmgMax() {
        return dmgMax;
    }

    public void setDmgMax(final int dmgMax) {
        this.dmgMax = dmgMax;
    }

    public int getDmgMin() {
        return dmgMin;
    }

    public void setDmgMin(final int dmgMin) {
        this.dmgMin = dmgMin;
    }

    public Location getNextMove() {
        return nextMove;
    }

    public void setNextMove(final Location nextMove) {
        this.nextMove = nextMove;
    }

    
}
